from rest_framework import serializers
from .models import Restaurant, Dish

class DishSerializer(serializers.ModelSerializer):
    class Meta:
        model = Dish
        fields = ['id', 'name', 'price', 'description', 'image', 'is_available']

class RestaurantSerializer(serializers.ModelSerializer):
    dishes = DishSerializer(many=True, read_only=True)
    rating = serializers.FloatField(read_only=True)
    
    class Meta:
        model = Restaurant
        fields = ['id', 'name', 'owner', 'address', 'phone', 'description', 
                 'image', 'rating', 'dishes', 'created_at']
